Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve response body mismatch error message #65

Closed
wants to merge 1 commit into from
Closed

Improve response body mismatch error message #65

wants to merge 1 commit into from

Conversation

kevinoid
Copy link

@kevinoid kevinoid commented Jun 2, 2013

Reviewer Note: I realize this may not be something you're interested in supporting. It has the down-side of changing behavior based on which modules are available. But I have found it to improve the usefulness of supertest a lot for my use cases and thought you might want to consider it.

If the parsed response body does not match the expected value, the
current output is only really useful in cases where the difference is
readily apparent or the body is small and the difference is in the
outermost object or its child. Otherwise the user may need to scroll
through large amounts of output and the mismatch may not be visible due
to the depth limit of util.inspect.

To make finding the source of inequality easier for users, make use of
either should or Chai assertions (which print very useful messages in
most test frameworks). When neither should nor Chai is available,
include the entire object in the output to allow users to find the
inequality when it is not in the outermost object or its child.

Signed-off-by: Kevin Locke kevin@kevinlocke.name

If the parsed response body does not match the expected value, the
current output is only really useful in cases where the difference is
readily apparent or the body is small and the difference is in the
outermost object or its child.  Otherwise the user may need to scroll
through large amounts of output and the mismatch may not be visible due
to the depth limit of util.inspect.

To make finding the source of inequality easier for users, make use of
either should or Chai assertions (which print very useful messages in
most test frameworks).  When neither should nor Chai is available,
include the entire object in the output to allow users to find the
inequality when it is not in the outermost object or its child.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
@tj
Copy link
Contributor

tj commented Jun 2, 2013

kinda hacky sorry :(

@tj tj closed this Jun 2, 2013
@kevinoid
Copy link
Author

kevinoid commented Jun 3, 2013

Not a problem, it is. Is there another solution that you'd find more acceptable?

@kevinoid
Copy link
Author

kevinoid commented Jun 4, 2013

Or, perhaps you don't agree that there is an issue?

@tj
Copy link
Contributor

tj commented Jun 4, 2013

I'll add some props for frameworks to use, it's a bit tricky to do the whole test framework agnostic thing, but I believe Chai did the same thing we did for should/mocha

@kevinoid
Copy link
Author

kevinoid commented Jun 4, 2013

Great. Much appreciated, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants